package com.controller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.model.Product;

public class ProductController extends Controller {
	
	public void list(){
		/**
		 * getPageNumber:当前页
		 * getPageSize：每页多少条数据
		 * getTotalPage：一共有多少页
		 * getTotalRow：一个有多少条数据
		 */
		
		Integer page = getParaToInt();
		Page<Product> productList = Product.productDao.paginate(page, 10, "SELECT *", "FROM t_product");
		setAttr("productList", productList);
		renderJsp("/WEB-INF/views/system/product/product_list.jsp");
	}
	
	public void index(){
		renderJsp("/WEB-INF/views/system/index.jsp");
	}
	
	public void index1(){
		renderJsp("/WEB-INF/views/system/top.jsp");
	}
	
	public void index2(){
		renderJsp("/WEB-INF/views/system/menu.jsp");
	}
	
	public void index3(){
		renderJsp("/WEB-INF/views/system/main.jsp");
	}
	
	public void input(){
		renderJsp("/WEB-INF/views/system/product/product_input.jsp");
	}
	
	public void delete(){
		Long id = getParaToLong();
		Product.productDao.deleteById(id);
		list();
	}
}
